package com.iplant.mes.service.po.qms;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.general.CalendarTool;
import com.iplant.basic.service.po.bpm.BPMTaskBase;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 来料检验单据
 * 2022-9-24 12:46:56
 *
 * @author:femi
 */
@Slf4j
@DBBasePO(TableName = "qms_material_check", Schemas = DBSchemas.MES, Name = false,
        CheckName = {"Code"}, CodeAuto = true, CodePrefix = "MCB-")
public class QMSMaterialCheck extends BPMTaskBase {


    /**
     * 物料ID
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.findInSet)
    @DBField
    public List<String> LotNo = new ArrayList<>();


    /**
     * 物料ID
     */
    @DBCondition
    @DBField(CheckValue = true)
    public int MaterialID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "mss_material", tableAsName = "m2", JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, MainTableField = "MaterialID")
    public String MaterialCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "mss_material", tableAsName = "m2", JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, MainTableField = "MaterialID")
    public String MaterialName = "";

    @DBJoin(name = "FileIDList", tableName = "mss_material", tableAsName = "m2", JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, MainTableField = "MaterialID")
    public List<Integer> FileIDList = new ArrayList<>();

    @DBJoinMulti(Name = "FileUrl", MainTableField = "FileIDList", TableName = "sfc_file", Schemas = DBSchemas.MES
    )
    public String CheckFile = "";

    /**
     * 物料组ID
     */
    @DBCondition
    @DBJoin(name = "MaterialGroupID", tableName = "mss_material", tableAsName = "m2", JoinMode =
            DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, MainTableField = "MaterialID")
    public int MaterialGroupID = 0;

    /**
     * 物料组编号
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "mss_materialgroup", tableAsName = "t3", Schemas = DBSchemas.Basic, JoinIndex = 3
            , ConditionalJoin = "m2.MaterialGroupID=t3.ID")
    public String MaterialGroupCode = "";
    /**
     * 物料组名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "mss_materialgroup", tableAsName = "t3", Schemas = DBSchemas.Basic, JoinIndex = 3
            , ConditionalJoin = "m2.MaterialGroupID=t3.ID")
    public String MaterialGroupName = "";

    @DBField(CheckValue = true)
    public double MaterialNumber = 0.0;
    @DBCondition
    @DBField
    public int CheckerID = 0;
    @DBJoinMulti(Name = "Name", TableName = "mbs_user", Schemas = DBSchemas.Basic, MainTableField =
            "CheckerID")
    public String CheckerName = "";

    @DBCondition
    @DBField(CheckValue = true)
    public int Result = 0;

    /**
     * 检查结果文件
     */
    @DBField
    public String CheckResultFile = "";

    /**
     * 供应商
     */
    @DBCondition
    @DBField
    public int SupplierID = 0;
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "crm_customer", tableAsName = "c2",
            Schemas = DBSchemas.Basic, MainTableField = "SupplierID")
    public String SupplierCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "crm_customer", tableAsName = "c2",
            Schemas = DBSchemas.Basic, MainTableField = "SupplierID")
    public String SupplierName = "";

    /**
     * 批次属性记录ID  同物料同一批收货的批次属性相同   单QRCode不同
     */
    @DBCondition
    @DBField(CheckValue = true)
    public int BatchRecordID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "RuleCode", tableName = "mss_batchrecord", Schemas = DBSchemas.WMS,
            tableAsName = "br1", MainTableField = "BatchRecordID")
    public String BatchRuleCode = "";


    @DBCondition
    @DBJoin(name = "Code", tableName = "mss_batchrecord", Schemas = DBSchemas.WMS,
            tableAsName = "br1", MainTableField = "BatchRecordID")
    public String BatchRecordCode = "";


    /**
     * 批次属性01 生产日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "ProductDateStart",
            ParamName2 = "ProductDateStartEnd")
    @DBJoin(name = "ProductDate", tableName = "mss_batchrecord", Schemas = DBSchemas.WMS,
            tableAsName = "br1", MainTableField = "BatchRecordID")
    public Calendar ProductDate = CalendarTool.getBasicDate();

    /**
     * 批次属性02 失效日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "ExpireDateStart",
            ParamName2 = "ExpireDateEnd")
    @DBJoin(name = "ExpireDate", tableName = "mss_batchrecord", Schemas = DBSchemas.WMS,
            tableAsName = "br1", MainTableField = "BatchRecordID")
    public Calendar ExpireDate = CalendarTool.getBasicDate();


    /**
     * 批次属性03 入库日期  收货即入库  上架并不改变入库日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "StockDateStart",
            ParamName2 = "StockDateEnd")
    @DBJoin(name = "StockDate", tableName = "mss_batchrecord", Schemas = DBSchemas.WMS,
            tableAsName = "br1", MainTableField = "BatchRecordID")
    public Calendar StockDate = CalendarTool.getBasicDate();

    /**
     * 不合格评审文件
     */
    @DBField
    public String NCRFiles = "";

    @JsonProperty("LotNo")
    public List<String> getLotNo() {
        return LotNo;
    }

    public void setLotNo(List<String> lotNo) {
        LotNo = lotNo;
    }

    @JsonProperty("MaterialID")
    public int getMaterialID() {
        return MaterialID;
    }

    public void setMaterialID(int materialID) {
        MaterialID = materialID;
    }

    @JsonProperty("MaterialCode")
    public String getMaterialCode() {
        return MaterialCode;
    }

    public void setMaterialCode(String materialCode) {
        MaterialCode = materialCode;
    }

    @JsonProperty("MaterialName")
    public String getMaterialName() {
        return MaterialName;
    }

    public void setMaterialName(String materialName) {
        MaterialName = materialName;
    }

    @JsonProperty("CheckFile")
    public String getCheckFile() {
        return CheckFile;
    }

    public void setCheckFile(String checkFile) {
        CheckFile = checkFile;
    }

    @JsonProperty("MaterialNumber")
    public double getMaterialNumber() {
        return MaterialNumber;
    }

    public void setMaterialNumber(double materialNumber) {
        MaterialNumber = materialNumber;
    }

    @JsonProperty("CheckerID")
    public int getCheckerID() {
        return CheckerID;
    }

    public void setCheckerID(int checkerID) {
        CheckerID = checkerID;
    }

    @JsonProperty("CheckerName")
    public String getCheckerName() {
        return CheckerName;
    }

    public void setCheckerName(String checkerName) {
        CheckerName = checkerName;
    }

    @JsonProperty("Result")
    public int getResult() {
        return Result;
    }

    public void setResult(int result) {
        Result = result;
    }

    @JsonProperty("SupplierID")
    public int getSupplierID() {
        return SupplierID;
    }

    public void setSupplierID(int supplierID) {
        SupplierID = supplierID;
    }

    @JsonProperty("SupplierCode")
    public String getSupplierCode() {
        return SupplierCode;
    }

    public void setSupplierCode(String supplierCode) {
        SupplierCode = supplierCode;
    }

    @JsonProperty("SupplierName")
    public String getSupplierName() {
        return SupplierName;
    }

    public void setSupplierName(String supplierName) {
        SupplierName = supplierName;
    }

    @JsonProperty("BatchRecordID")
    public int getBatchRecordID() {
        return BatchRecordID;
    }

    public void setBatchRecordID(int batchRecordID) {
        BatchRecordID = batchRecordID;
    }

    @JsonProperty("BatchRuleCode")
    public String getBatchRuleCode() {
        return BatchRuleCode;
    }

    public void setBatchRuleCode(String batchRuleCode) {
        BatchRuleCode = batchRuleCode;
    }

    @JsonProperty("BatchRecordCode")
    public String getBatchRecordCode() {
        return BatchRecordCode;
    }

    public void setBatchRecordCode(String batchRecordCode) {
        BatchRecordCode = batchRecordCode;
    }

    @JsonProperty("ProductDate")
    public Calendar getProductDate() {
        return ProductDate;
    }

    public void setProductDate(Calendar productDate) {
        ProductDate = productDate;
    }

    @JsonProperty("ExpireDate")
    public Calendar getExpireDate() {
        return ExpireDate;
    }

    public void setExpireDate(Calendar expireDate) {
        ExpireDate = expireDate;
    }

    @JsonProperty("StockDate")
    public Calendar getStockDate() {
        return StockDate;
    }

    public void setStockDate(Calendar stockDate) {
        StockDate = stockDate;
    }

    @JsonProperty("CheckResultFile")
    public String getCheckResultFile() {
        return CheckResultFile;
    }

    public void setCheckResultFile(String checkResultFile) {
        CheckResultFile = checkResultFile;
    }

    @JsonProperty("NCRFiles")
    public String getNCRFiles() {
        return NCRFiles;
    }

    public void setNCRFiles(String NCRFiles) {
        this.NCRFiles = NCRFiles;
    }

    @JsonProperty("FileIDList")
    public List<Integer> getFileIDList() {
        return FileIDList;
    }

    public void setFileIDList(List<Integer> fileIDList) {
        FileIDList = fileIDList;
    }

    @JsonProperty("MaterialGroupID")
    public int getMaterialGroupID() {
        return MaterialGroupID;
    }

    public void setMaterialGroupID(int materialGroupID) {
        MaterialGroupID = materialGroupID;
    }

    @JsonProperty("MaterialGroupCode")
    public String getMaterialGroupCode() {
        return MaterialGroupCode;
    }

    public void setMaterialGroupCode(String materialGroupCode) {
        MaterialGroupCode = materialGroupCode;
    }

    @JsonProperty("MaterialGroupName")
    public String getMaterialGroupName() {
        return MaterialGroupName;
    }

    public void setMaterialGroupName(String materialGroupName) {
        MaterialGroupName = materialGroupName;
    }
}
